<template>
  <div class="home-container">
    <van-nav-bar id="page-nav-bar" fixed>
      <van-button round class="home-search" slot="title" type="info" icon="search">搜索</van-button>
    </van-nav-bar>
    <!-- tab栏 -->
    <van-tabs animated swipeable class="home-vanTab">
      <van-tab :title="item.name" v-for="item in channel" :key="item.id">
        <article-list :channel="item" />
      </van-tab>
      <div class="placeholder" slot="nav-right"></div>
      <div class="hamburger-btn" slot="nav-right">
        <i class="iconfont icongengduo"></i>
      </div>
    </van-tabs>
  </div>
</template>

<script>
import { getUserChannels } from '@/api/user'
import articleList from './artcleList'
export default {
  data() {
    return {
      channel: []
    }
  },
  components: {
    articleList
  },
  created() {
    this.loadUserChannels()
  },
  methods: {
    async loadUserChannels() {
      try {
        const { data: res } = await getUserChannels()
        console.log(res.data)
        this.channel = res.data.channels
      } catch (err) {
        this.$toast('获取用户频道列表失败')
      }
    }
  }
}
</script>

<style lang="less" >
.home-container {
  padding-top: 174px;
  padding-bottom: 100px;
  .van-nav-bar__title {
    max-width: unset;
  }
  .home-search {
    width: 555px;
    height: 64px;
    background-color: #5babfb;
    font-size: 28px;
    .van-icon-search::before {
      color: white;
      font-size: 32px;
    }
  }
  .home-vanTab {
    .van-tabs__wrap {
      height: 82px;
      position: fixed;
      top: 92px;
      left: 0;
      right: 0;
      z-index: 1;
    }
    .van-tab {
      border-right: 1px solid #edeff3;
      min-width: 200px;
      font-size: 30px;
      color: #777;

      // flex: 0 0 10%;
    }
    .van-tab--active {
      color: #333;
    }
    .van-tabs__nav {
      padding-bottom: 0;
    }
    .van-tabs__line {
      background-color: #3296fa;
      width: 31px !important;
      height: 6px;
      bottom: 8px;
    }
  }
  .placeholder {
    width: 66px;
    height: 82px;
    flex-shrink: 0;
  }
  .hamburger-btn {
    position: fixed;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 66px;
    height: 82px;
    background-color: #fff;
    opacity: 0.7;

    i.iconfont {
      font-size: 33px;
    }
    &:before {
      content: '';
      width: 2px;
      position: absolute;
      left: 0;
      height: 100%;
      background: url(~@/assets/gradient-gray-line.png);
      background-size: contain;
    }
  }
}
</style>
